class Weapon(object):
    
    def __init__(self, weapon_type, dps, speed, enchant):
        self.weapon_type = weapon_type
        self.dps = dps
        self.speed = speed
        self.dph = dps * speed
        self.enchant = enchant
        
        
class Enchant(object):
    
    MOP_ENCHANTS = {'WINDSONG':{'VALUE':1500.0, 'TYPE':'RPPM', 'CHANCE':2.0/3, 'STATS':['mastery', 'haste', 'crit'], 'LAST':12},
                    'DANCING_STEEL':{'VALUE':1650.0, 'TYPE':'RPPM', 'CHANCE':2.0, 'STATS':['agi'], 'LAST':12}
                    }
    
    def __init__(self, name):
        self.name = name
        self.proc = self.MOP_ENCHANTS.get(name)
        
        
    def get_uptime(self, aps, haste, dw_same=False):
        if self.proc.get('TYPE') == 'RPPM':
            proc_chance =  haste * (self.proc.get('CHANCE') / aps) / 60.0
            if dw_same:
                proc_chance *= 2
        last = self.proc.get('LAST')
        uptime = 1 - ((1 - proc_chance) ** (last * aps))
        
        return uptime
    
    def get_stats_from_enchant(self):
        stats = {}
        proc_stats = self.proc.get('STATS')
        proc_value = self.proc.get('VALUE')
        for stat in proc_stats:
            stats[stat] = proc_value
        return stats